﻿using System;

namespace OperationPlugins
{
    /// <summary>
    /// Used to tell that a plugin only applies to the specified OperationId.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public class OperationFilterAttribute : Attribute
    {
        private readonly string _operationId;

        /// <summary>
        /// Initializes a new instance of the OperationFilterAttribute class.
        /// </summary>
        /// <param name="operationId">OperationId</param>
        public OperationFilterAttribute(string operationId)
        {
            if (operationId == null)
            {
                throw new ArgumentNullException("operationId");
            }

            _operationId = operationId;
        }

        /// <summary>
        /// Gets the OperationId.
        /// </summary>
        public virtual string Value
        {
            get { return _operationId; }
        }
    }

    internal sealed class InternalOperationFilterAttribute : OperationFilterAttribute
    {
        public InternalOperationFilterAttribute() : base(Operations.InternalOperationId)
        {            
        }
    }

}